package com.bilin.coin.activity;

import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.bilin.coin.R;
import com.bilin.coin.common.base.BaseAppCompatActivity;
import com.bilin.coin.tools.Poster;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;


@Route(path = "/safe/LowAuthActivity")
public class LowAuthActivity extends BaseAppCompatActivity {

    @BindView(R.id.et_user_name)
    EditText et_user_name;
    @BindView(R.id.et_user_id)
    EditText et_user_id;

    String idCardNo;
    String name;

    @Override
    protected void initView() {

        setTitle("身份认证");
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_auth_low;
    }

    @OnClick({R.id.bt_confirm})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.bt_confirm:
                auth();
                break;
        }
    }

    private void auth() {
        idCardNo = et_user_id.getText().toString().trim();
        name = et_user_name.getText().toString().trim();
        if (TextUtils.isEmpty(idCardNo)) {
            showToast("身份证件号为空");
            return;
        }
        if (TextUtils.isEmpty(name)) {
            showToast("姓名不能为空");
            return;
        }
        new Poster(this) {
            @Override
            protected String fillUrl() {
                return "/api/user/kyc";
            }

            @Override
            protected Map<String, String> fillParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("idCardNo",idCardNo);
                hashMap.put("name",name);
                return hashMap;
            }

            @Override
            protected void disposeSuccess(String dataJson) {
                super.disposeSuccess(dataJson);
                baseStartActivityWith("/v2/safe/AuthActivity")
                        .withString("idCardNo", idCardNo)
                        .withString("name", name)
                        .navigation();
                finish();
            }
        };

    }
}
